package org.example.domain.strategy.model.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.example.types.common.Constants;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class StrategyEntity {
    private Long strategyId;
    private String  strategyDesc;
    private String ruleModels;//抽奖规则模型

    public  String[] ruleModels(){
        if(StringUtils.isBlank(ruleModels))return null;
        return ruleModels.split(Constants.SPLIT);
    }

    public String getRuleWeight(){
        String [] ruleModels=this.ruleModels();
        if(null==ruleModels)return null;
        for (String ruleModel :ruleModels){
            if("rule_weight".equals(ruleModel))return ruleModel;
        }
        return null;

    }

}
